package com.foxinmy.weixin4j.server.test;

import java.io.IOException;
import java.net.URI;

import com.leige.utils.tool.HttpClient;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
import com.squareup.okhttp.internal.http.StatusLine;

/**
 * 发送消息请求到服务器
 * 
 * @className MessagePush
 * @author jinyu(foxinmy@gmail.com)
 * @date 2015年5月8日
 * @since JDK 1.6
 * @see
 */
public class MessagePush {

	private final String server = "http://localhost:30000";
	private final HttpClient httpClient;

	public MessagePush() {
		httpClient = new HttpClient();
		
	}

	public String get(String para) throws IOException {
		return httpClient.getBody(server + para);
	}

	public String push(String xml) throws IOException {
		return push("", xml);
	}

	public String push(String para, String xml) throws IOException {
		Response httpResponse=null;
		try {
			httpResponse= httpClient.post(server + para, xml);
			String responseBody = httpResponse.body().string();
			return responseBody;
		} finally{
			if(httpResponse!=null)httpResponse.code();
		}
	}

}